| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkGraphics::Renderer Class Referenceabstract

A renderer, implementing the logic of using a graphics API. More...

## Public Member Functions
| Renderer () noexcept
virtual | ~Renderer ()
virtual DataAllocator * | getAllocator () const =0
virtual RendererSupportInfo | getRendererSupportInfo () const =0
virtual nkMemory::UniquePtr< nkExport::Node > | getStats () const =0
RENDERING_API | getRenderApi () const
virtual bool | initialize (const Configuration &config)=0
virtual bool | initiateBuiltInShaders ()=0
virtual bool | postGraphicSystemInit ()=0
virtual void | prepareForRelease ()=0
virtual bool | shutdown ()=0
virtual void | flushRendering ()=0
virtual void | preRenderRoutine ()=0
virtual void | postRenderRoutine ()=0
virtual bool | launchComputeShader (Shader *shader, unsigned int xThread, unsigned int yThread, unsigned int zThread)=0
virtual bool | launchGeometryShaderStream (Shader *shader, Mesh *baseMesh, Mesh *outputMesh, Buffer *outputBuffer, bool gpuCopy=false, bool async=false)=0

## Detailed Description

A renderer, implementing the logic of using a graphics API.

There is one per supported graphics API, and it is chosen at startup based on the configuration provided and the capabilities of the machine. In theory, external code should only use this class to :

- Flush the rendering pipeline (and ensure nothing is left working on the GPU)
- Retrieve internal statistics about the rendering
- Retrieve compatibility reports about various features GPU can or cannot support

## Constructor & Destructor Documentation

## ◆ Renderer()

nkGraphics::Renderer::Renderer | ( |  | ) |
| noexcept

Constructor.

## ◆ ~Renderer()

virtual nkGraphics::Renderer::~Renderer | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ getAllocator()

virtual DataAllocator* nkGraphics::Renderer::getAllocator | ( |  | ) | const
| pure virtual

Returns
  The data allocator for the renderer. Drives all the allocations for renderer dependent resources.

Remarks
  In theory, this function should not be called by external code. To allocate a resource, call the corresponding Manager.

## ◆ getRendererSupportInfo()

virtual RendererSupportInfo nkGraphics::Renderer::getRendererSupportInfo | ( |  | ) | const
| pure virtual

Returns
  The supported features for the renderer and hardware.

## ◆ getStats()

virtual nkMemory::UniquePtr<nkExport::Node> nkGraphics::Renderer::getStats | ( |  | ) | const
| pure virtual

Returns
  Statistics about the renderer, such as memory consumption.

Remarks
  The statistics returned depend on which renderer type is being used, as each renderer works differently internally. As such, a data tree is returned, featuring members describing the stats the renderer wishes to expose. If necessary, a human readable version can be generated using nkExport's Json capabilities.

## ◆ getRenderApi()

RENDERING_API nkGraphics::Renderer::getRenderApi | ( |  | ) | const

Returns
  The rendering API associated to the renderer.

## ◆ initialize()

virtual bool nkGraphics::Renderer::initialize | ( | const Configuration & | config | ) |
| pure virtual

Initializes the renderer given a configuration. This is taken care of by the component initialization process and should not be called by external code.

Parameters

  config | The configuration to use to initialize the renderer.

Returns
  If the initalization went well.

## ◆ initiateBuiltInShaders()

virtual bool nkGraphics::Renderer::initiateBuiltInShaders | ( |  | ) |
| pure virtual

Initializes the built in shaders. This is taken care of by the component initialization process and should not be called by external code.

Returns
  If the initalization went well.

## ◆ postGraphicSystemInit()

virtual bool nkGraphics::Renderer::postGraphicSystemInit | ( |  | ) |
| pure virtual

Post initialization step. This is taken care of by the component initialization process and should not be called by external code.

Returns
  If the initalization went well.

## ◆ prepareForRelease()

virtual void nkGraphics::Renderer::prepareForRelease | ( |  | ) |
| pure virtual

Prepares the renderer for shutdown. This is taken care of by the component initialization process and should not be called by external code.

## ◆ shutdown()

virtual bool nkGraphics::Renderer::shutdown | ( |  | ) |
| pure virtual

Shuts down the renderer and frees all related memory. This is taken care of by the component initialization process and should not be called by external code.

Returns
  If the shutdown went well.

## ◆ flushRendering()

virtual void nkGraphics::Renderer::flushRendering | ( |  | ) |
| pure virtual

Flushes the rendering pipeline. This ensures that :

- The engine finishes all pending work
- The GPU finishes all work that has been submitted

This can be used to ensure a resource will be available next frame, for instance, as they can be loaded in async.

## ◆ preRenderRoutine()

virtual void nkGraphics::Renderer::preRenderRoutine | ( |  | ) |
| pure virtual

A pre render step, part of the rendering process. In theory, should never be called by external code.

## ◆ postRenderRoutine()

virtual void nkGraphics::Renderer::postRenderRoutine | ( |  | ) |
| pure virtual

A post render step, part of the rendering process. In theory, should never be called by external code.

## ◆ launchComputeShader()

virtual bool nkGraphics::Renderer::launchComputeShader | ( | Shader * | shader,
|  | unsigned int | xThread,
|  | unsigned int | yThread,
|  | unsigned int | zThread
| ) |  |
| pure virtual

Used to launch a compute shader, once. Can be used when a specific shader needs to be launched once, in a ponctual manner. Keep in mind that this API is possibly disappearing soon, as it is better to use the compositor and let it schedule work. For now, as no alternative exists, this is left available.

Parameters

  shader | The shader to use.
  xThread | The x dimension for threads to launch.
  yThread | The y dimension for threads to launch.
  zThread | The z dimension for threads to launch.

Returns
  If the process succeeded.

## ◆ launchGeometryShaderStream()

virtual bool nkGraphics::Renderer::launchGeometryShaderStream | ( | Shader * | shader,
|  | Mesh * | baseMesh,
|  | Mesh * | outputMesh,
|  | Buffer * | outputBuffer,
|  | bool | gpuCopy = `false`,
|  | bool | async = `false`
| ) |  |
| pure virtual

Used to launch a geometry stream, once. Can be used to launch a geometry pipeline that will output data in a buffer, for later reuse. Keep in mind that this API is possibly disappearing or moving soon, as it is better to use the compositor and let it schedule work. For now, as no alternative exists, this is left available.

Parameters

  shader | The geometry shader to use.
  baseMesh | The base mesh to feed the vertex shader.
  outputMesh | The mesh to output data to.
  outputBuffer | If no outputMesh is used, data will end in the buffer specified.
  gpuCopy | If the output of data should happen on gpu.
  async | If the process can happen in async, or if there is a need to wait for the result.

Returns
  If the process succeeded.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsGraphics/Renderers/Renderer.h